Skip to content

fix(model_runner): map Vertex AI headers via http_options and enable vertexai SDK extra#74

Open
MasakiMu319 wants to merge 2 commits intobubbuild:mainfrom
MasakiMu319:main
Open

fix(model_runner): map Vertex AI headers via http_options and enable vertexai SDK extra#74
MasakiMu319 wants to merge 2 commits intobubbuild:mainfrom
MasakiMu319:main

Conversation

@MasakiMu319
Copy link

Summary

This PR fixes a provider-specific request mapping issue for Vertex AI and adds the required Vertex AI SDK
extra in dependencies.

When using vertexai:* models, Bub previously passed extra_headers into the LLM call. In the Vertex AI
path, that value is validated against GenerateContentConfig, where extra_headers is invalid, causing
runtime errors.

What Changed

  • Updated ModelRunner request construction:
  • For vertexai:* models, pass headers via http_options={"headers": ...}.
  • For non-Vertex providers, keep the default behavior and pass extra_headers.
  • Added regression coverage in tests/test_model_runner.py:
  • OpenRouter/non-Vertex path still uses extra_headers.
  • Vertex AI path uses http_options.headers and does not send extra_headers.
  • Unknown providers continue using default extra_headers.
  • Updated dependencies:
  • any-llm-sdk[anthropic] -> any-llm-sdk[anthropic,vertexai]
  • Synced lockfile accordingly.

Why

This PR fixes a provider-parameter mismatch that is reproducible with Vertex AI:

  • Set BUB_MODEL=vertexai:gemini-3.1-pro-preview
  • Run uv run bub and send a simple message
  • Before this change, Bub passed extra_headers in the model call
  • In the Vertex AI path, forwarded kwargs are validated against GenerateContentConfig, where
    extra_headers is invalid
  • This caused runtime failure: GenerateContentConfig ... extra_headers ... Extra inputs are not permitted

The fix maps headers correctly for Vertex AI (http_options.headers) while keeping default extra_headers
behavior for non-Vertex providers.

Validation

  • uv run pytest -q tests/test_model_runner.py (11 passed)

  • uv run ruff check src/bub/core/model_runner.py tests/test_model_runner.py (passed)

  • Fixes Vertex AI runtime failure (extra_headers validation error).

  • Preserves existing behavior for non-Vertex providers.

  • No public API changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant